function Shape() {
	this.x = 0;
	this.y = 0;

	this.move = function(x, y) {
		this.x = x;
		this.y = y;
	}

	this.distanceFromOrigin = function() {
		return Math.sqrt(this.x * this.x + this.y * this.y);
	}
}

var s1 = new Shape(), s2 = new Shape();
s1.move(10, 10);
s2.move(20, 20);
console.log("s1: " + s1.distanceFromOrigin());
console.log("s2: " + s2.distanceFromOrigin());

function ShapeBase(x, y) {this.x = x; this.y = y}
ShapeBase.prototype.x = 0;
ShapeBase.prototype.y = 0;

ShapeBase.prototype.move = function(x, y) {
	this.x = x;
	this.y = y;
}

ShapeBase.prototype.distanceFromOrigin = function() {
	return Math.sqrt(this.x * this.x + this.y * this.y);
}

ShapeBase.prototype.area = function() {
	throw new Error("I don't have a form yet");
}

var s3 = new ShapeBase(), s4 = new ShapeBase();
s3.move(10, 10);
s4.move(20, 20);

console.log("s3: " + s3.distanceFromOrigin());
console.log("s4: " + s4.distanceFromOrigin());

var s5 = new ShapeBase(20, 20);
console.log("s5: " + s5.distanceFromOrigin());


// Square
console.time("test-time");

function Square() {}
Square.prototype = new ShapeBase();
// Square.prototype.__proto__ = ShapeBase.prototype;
Square.prototype.width = 0;
Square.prototype.area = function() {
	return this.width * this.width;
}

var sq1 = new Square(), sq2 = new Square();
sq1.move(-5, -5);
sq1.width = 5;
sq2.move(-5, -5);
sq2.width = 5;
console.log("sq1: " + sq1.area());
console.log("sq1: " + sq1.distanceFromOrigin());

console.log("sq2: " + sq2.area());
console.log("sq2: " + sq2.distanceFromOrigin());

setTimeout(function() {
	console.log("I've done my work");
}, 1000)

console.log("I'm waiting for all my work to finish")
console.timeEnd("test-time");



